#! /usr/bin/env python
# -*- coding:utf-8 -*-
#author:无涯
import requests

from base.method import ApiHttp
import  pytest
from utils.operationJson import readJson
from  utils.operationYaml import  *

obj=ApiHttp()


def pytest_addoption(parser):
   parser.addoption(
      '--username',action='store',default='wuya',help='myoption: type1 or pyte2'
   )
   parser.addoption(
   '--password',action='store',default='admin',help='myoption: type1 or pyte2')

@pytest.fixture()
def username(request):
   return request.config.getoption('--username')

@pytest.fixture()
def password(request):
   return request.config.getoption('--password')

@pytest.fixture()
def login(username,password):
	data = readJson()['login']
	data['username'] = username
	data['password'] = password
	r=obj.post(
		url=getUrl()+"/login/auth/",
		json=data)
	return r.json()['token']


@pytest.fixture()
def headers(login):
	return {'Authorization':'JWT {token}'.format(token=login)}


